package com.mimi.practice.database

import android.content.Context
import androidx.room.Database
import androidx.room.Room
import androidx.room.RoomDatabase
import com.mimi.practice.database.bean.PairDevEntity
import com.mimi.practice.database.dao.PairDevEntityDao

@Database(entities = [PairDevEntity::class], version = 1)
abstract class DbManager : RoomDatabase() {

    companion object {

        private var instance: DbManager? = null

        @Synchronized
        fun getDatabase(context: Context): DbManager {
            instance?.let {
                return it
            }
            return Room.databaseBuilder(context.applicationContext,
                DbManager::class.java,
                "app_database").build().apply {
                instance = this
            }
        }
    }

    abstract fun pairDevEntityDao(): PairDevEntityDao

}